cmake_minimum_required(VERSION 3.0.2)
project(livelybot_serial)

# Find catkin
find_package(catkin REQUIRED COMPONENTS
    roscpp
    std_msgs
    livelybot_msg  
    serial
    sensor_msgs
    tf
    urdf
)

# 查找 pinocchio 库
find_package(pinocchio REQUIRED)

set(rt_LIBRARIES rt)
set(pthread_LIBRARIES pthread)

set(serial_SRCS
    include/hardware/robot.h
    include/hardware/motor.h
    src/lively_serial.cc
    src/hardware/motor.cc
)

catkin_package(
    LIBRARIES ${PROJECT_NAME}
    INCLUDE_DIRS include
    DEPENDS rt pthread
    CATKIN_DEPENDS roscpp std_msgs livelybot_msg serial
)
add_library(${PROJECT_NAME} ${serial_SRCS})


target_link_libraries(${PROJECT_NAME} rt pthread)
include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  ${pinocchio_INCLUDE_DIRS}
)
# # test
# add_executable(testArm src/testArm.cpp ${serial_SRCS})
# target_link_libraries(testArm ${catkin_LIBRARIES})

# #myARM
# add_executable(myARM src/myARM.cpp  ${serial_SRCS})
# target_link_libraries(myARM ${catkin_LIBRARIES} ${pinocchio_LIBRARIES})

# #ikTest
# add_executable(ikTest src/ikTest.cpp  ${serial_SRCS})
# target_link_libraries(ikTest ${catkin_LIBRARIES} ${pinocchio_LIBRARIES})

#arm_7dof_driver
add_executable(arm_7dof_driver src/arm_7dof_driver.cpp  ${serial_SRCS})
target_link_libraries(arm_7dof_driver ${catkin_LIBRARIES} ${pinocchio_LIBRARIES})

#arm_7dof_trajectory_action
add_executable(arm_7dof_trajectory_action src/arm_7dof_trajectory_action.cpp)
target_link_libraries(arm_7dof_trajectory_action ${catkin_LIBRARIES} ${pinocchio_LIBRARIES})


#myARM_7dof
add_executable(myARM_7dof src/myARM_7dof.cpp  ${serial_SRCS})
target_link_libraries(myARM_7dof ${catkin_LIBRARIES} ${pinocchio_LIBRARIES})

install(TARGETS ${PROJECT_NAME}
    ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
    LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
    RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
)

## Install headers
install(FILES include/hardware/robot.h include/hardware/motor.h
  DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}/livelybot_serial)
